package test6;

import java.io.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Hua YY
 * Date: 2025-02-05
 * Time: 13:48
 */

class Person implements Cloneable {
    public String name;
    public int age;
    public Address address;
    public Person(String name , int age , Address address){
        this.name = name;
        this.age = age;
        this.address = address;
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}
class Address implements Serializable{
    public String city;
    public Address(String city){
        this.city = city;
    }
}
public class Test3 {
    public static void main(String[] args) throws CloneNotSupportedException {
        Address address = new Address("杭州");
        Person person1 = new Person("张三",18,address);
        Person person2 = (Person) person1.clone();
        System.out.println(person1.address == person2.address);
        person1.address.city = "北京";

        System.out.println(person1.address.city);
        System.out.println(person2.address.city);
    }
}
